<?php
/*Template Name: Contact Us */
 get_header(); ?>

<div class="six columns">
    <form action="" method="post" onsubmit="return formValidator()">
	<label >Name</label>	
	<input type="text" name="name" id="name" value="" placeholder="Your name" required="required"/>

	<label >Email</label>	
	<input type="email" name="email" id="email" value="" placeholder="Your email" required="required"/>

    <?php if($NHP_Options->get('address_input') == '1') { ?>
	<label >Address</label>	
	<input type="text" name="add" value="" placeholder="Your address"/>
    <?php } ?>
    
    <?php if($NHP_Options->get('phone_input') == '1') { ?>
	<label >Phone</label>	
	<input type="text" name="phone" value="" placeholder="Your phone"/>
    <?php } ?>
    
    <?php if($NHP_Options->get('website_input') == '1') { ?>
	<label >Website</label>	
	<input type="text" name="website" value="" placeholder="Your website"/>
    <?php } ?>
    
	<label >Subject</label>	
	<textarea name="subject"></textarea>

	
	<input type="submit" name="submit" value="Send" />	

    </form>
</div>
<?php 
  
    
    if(isset($_POST['submit'])){
        
        $to = $NHP_Options->get('email');
        
        
        $name = $_POST['name'];
        $email = $_POST['email'];
        
        $subject = $name.',hello.';
        $message = $_POST['subject'];
        
        $headers[] = "From: $email";
        $headers[] = "Cc: John Q Codex";
       
        if(   wp_mail( $to, $subject, $message, $headers )    )
            echo  "<script type='text/javascript'> alert('Email send success.Thank you!')</script>";
        else echo  "<script type='text/javascript'> alert('Email not send.Please check again.')</script>";
        
    }
?>
<div class="six columns">
    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
    </script>
    <script>
            var myCenter=new google.maps.LatLng(21.574442,105.826435);
            
            function initialize()
            {
            var mapProp = {
              center:myCenter,
              zoom:5,
              mapTypeId:google.maps.MapTypeId.ROADMAP
              };
            
            var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
            
            var marker=new google.maps.Marker({
              position:myCenter,
              });
            
            marker.setMap(map);
            }
            
            google.maps.event.addDomListener(window, 'load', initialize);
    </script>
    <div id="googleMap" style="width:430px;height:380px;" ></div>
</div>


		
<?php get_footer(); ?>